<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-windows;$(NetCoreAppMinimum)-unix;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
    <TargetFrameworks Condition="'$(NetCoreAppPrevious)' != ''">$(TargetFrameworks);$(NetCoreAppPrevious)-windows;$(NetCoreAppPrevious)-unix;$(NetCoreAppPrevious)</TargetFrameworks>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <DefineConstants>$(DefineConstants);SERIAL_PORTS</DefineConstants>
    <IncludeDllSafeSearchPathAttribute>true</IncludeDllSafeSearchPathAttribute>
    <UseCompilerGeneratedDocXmlFile>false</UseCompilerGeneratedDocXmlFile>
    <IsPackable>true</IsPackable>
    <PackageDescription>Provides classes for controlling serial ports.

Commonly Used Types:
System.IO.Ports.SerialPort</PackageDescription>

    <!-- TODO https://github.com/dotnet/runtime/issues/90400: Annotate for nullable reference types -->
    <Nullable>disable</Nullable>
    <NoWarn>$(NoWarn);nullable</NoWarn>
  </PropertyGroup>

  <!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
  <PropertyGroup>
    <TargetPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</TargetPlatformIdentifier>
    <IsPartialFacadeAssembly Condition="$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) == '.NETFramework'">true</IsPartialFacadeAssembly>
    <GeneratePlatformNotSupportedAssemblyMessage Condition="'$(IsPartialFacadeAssembly)' != 'true' and '$(TargetPlatformIdentifier)' == ''">SR.PlatformNotSupported_IOPorts</GeneratePlatformNotSupportedAssemblyMessage>
  </PropertyGroup>

  <ItemGroup Condition="'$(TargetPlatformIdentifier)' != ''">
    <Compile Include="System\IO\Ports\Handshake.cs" />
    <Compile Include="System\IO\Ports\InternalResources.cs" />
    <Compile Include="System\IO\Ports\Parity.cs" />
    <Compile Include="System\IO\Ports\SerialData.cs" />
    <Compile Include="System\IO\Ports\SerialDataReceivedEventArgs.cs" />
    <Compile Include="System\IO\Ports\SerialDataReceivedEventHandler.cs" />
    <Compile Include="System\IO\Ports\SerialError.cs" />
    <Compile Include="System\IO\Ports\SerialErrorReceivedEventArgs.cs" />
    <Compile Include="System\IO\Ports\SerialErrorReceivedEventHandler.cs" />
    <Compile Include="System\IO\Ports\SerialPinChange.cs" />
    <Compile Include="System\IO\Ports\SerialPinChangedEventArgs.cs" />
    <Compile Include="System\IO\Ports\SerialPinChangedEventHandler.cs" />
    <Compile Include="System\IO\Ports\SerialPort.cs" />
    <Compile Include="System\IO\Ports\SerialStream.cs" />
    <Compile Include="System\IO\Ports\StopBits.cs" />
    <Compile Include="$(CommonPath)DisableRuntimeMarshalling.cs"
             Link="Common\DisableRuntimeMarshalling.cs" />
  </ItemGroup>

  <ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'windows'">
    <Compile Include="System\IO\Ports\SerialStream.Windows.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.DCB.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.DCB.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.COMMPROP.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.COMMPROP.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.COMMTIMEOUTS.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.COMMTIMEOUTS.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.COMSTAT.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.COMSTAT.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.SetCommState.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.SetCommState.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.SetCommBreak.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.SetCommBreak.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.ClearCommBreak.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.ClearCommBreak.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.EscapeCommFunction.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.EscapeCommFunction.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.SetCommTimeouts.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.SetCommTimeouts.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetCommModemStatus.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.GetCommModemStatus.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.ClearCommError.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.ClearCommError.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetCommProperties.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.GetCommProperties.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.SetCommMask.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.SetCommMask.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.PurgeComm.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.PurgeComm.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.SetupComm.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.SetupComm.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetCommState.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.GetCommState.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.WaitCommEvent.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.WaitCommEvent.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.ReadFile_SafeHandle_IntPtr.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.ReadFile_SafeHandle_IntPtr.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.ReadFile_SafeHandle_NativeOverlapped.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.ReadFile_SafeHandle_NativeOverlapped.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_IntPtr.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_IntPtr.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_NativeOverlapped.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_NativeOverlapped.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetOverlappedResult.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.GetOverlappedResult.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.FlushFileBuffers.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.FlushFileBuffers.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GenericOperations.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.GenericOperations.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.SECURITY_ATTRIBUTES.cs"
             Link="Common\Interop\Windows\Interop.SECURITY_ATTRIBUTES.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.FileTypes.cs"
             Link="Common\Interop\Windows\Interop.FileTypes.cs" />
    <Compile Include="$(CommonPath)System\Text\ValueStringBuilder.cs"
             Link="Common\System\Text\ValueStringBuilder.cs" />
    <Compile Include="$(CommonPath)System\IO\PathInternal.Windows.cs"
             Link="Common\System\IO\PathInternal.Windows.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.GetFileType_SafeHandle.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.GetFileType_SafeHandle.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Interop.Libraries.cs"
             Link="Common\Interop\Windows\Interop.Libraries.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Interop.Errors.cs"
             Link="Common\Interop\Windows\Interop.Errors.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Interop.BOOL.cs"
             Link="Common\Interop\Windows\Interop.BOOL.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.CloseHandle.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.CloseHandle.cs" />
    <Compile Include="$(CommonPath)System\IO\Win32Marshal.cs"
             Link="Common\System\IO\Win32Marshal.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.FormatMessage.cs"
             Link="Common\Interop\Windows\Interop.FormatMessage.cs" />
    <Compile Include="System\IO\Ports\SerialPort.Win32.cs" />
    <Compile Include="System\IO\Ports\SerialStream.Win32.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.CreateFile.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.CreateFile.cs" />
    <Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.FileOperations.cs"
             Link="Common\Interop\Windows\Kernel32\Interop.FileOperations.cs" />
  </ItemGroup>

  <ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'unix'">
    <Compile Include="System\IO\Ports\SafeSerialDeviceHandle.Unix.cs" />
    <Compile Include="System\IO\Ports\SerialPort.Unix.cs" />
    <Compile Include="System\IO\Ports\SerialStream.Unix.cs" />
    <Compile Include="$(CommonPath)Interop\Unix\System.IO.Ports.Native\Interop.Termios.cs"
             Link="Common\Interop\Unix\System.IO.Ports.Native\Interop.Termios.cs"/>
    <Compile Include="$(CommonPath)Interop\Unix\System.IO.Ports.Native\Interop.Serial.cs"
             Link="Common\Interop\Unix\System.IO.Ports.Native\Interop.Serial.cs"/>
    <Compile Include="$(CommonPath)Interop\Unix\Interop.Libraries.cs"
             Link="Common\Interop\Unix\Interop.Libraries.cs" />
    <Compile Include="$(CommonPath)Interop\Unix\Interop.Errors.cs"
             Link="Common\Interop\Unix\Interop.Errors.cs" />
    <Compile Include="$(CommonPath)Interop\Unix\Interop.IOErrors.cs"
             Link="Common\Interop\Unix\Interop.IOErrors.cs" />
    <Compile Include="$(CommonPath)Interop\Unix\Interop.Poll.Structs.cs"
             Link="Common\Interop\Unix\Interop.Poll.Structs.cs" />
  </ItemGroup>

  <ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
    <Compile Include="$(CommonPath)System\Threading\Tasks\TaskToAsyncResult.cs" Link="Common\System\Threading\Tasks\TaskToAsyncResult.cs" />
  </ItemGroup>

  <ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
    <!-- Just reference the runtime packages but don't build them in order to avoid unintentional Build/Pack invocations. -->
    <ProjectReference Include="..\pkg\runtime.native.$(MSBuildProjectName).proj" BuildReference="false" />
    <!-- Make the runtime specific packages non transitive so that they aren't flowing into other projects. -->
    <ProjectReference Include="..\pkg\runtime.*.runtime.native.$(MSBuildProjectName).proj" BuildReference="false" PrivateAssets="all" />
  </ItemGroup>

</Project>
